package com.gitee.l0km.thrift.swift2thrift.generator;

import java.util.Locale;

import org.stringtemplate.v4.AttributeRenderer;

import com.facebook.swift.codec.ThriftField;

public class EnumErpcRender implements AttributeRenderer {

	public EnumErpcRender() {
	}

	@Override
	public String toString(Object o, String formatString, Locale locale) {
		if(o instanceof ThriftField.Requiredness ){
			ThriftField.Requiredness req = (ThriftField.Requiredness)o;
			switch (req) {
			case OPTIONAL:
				return " @nullable";
			default:
				return "";
			}
		}
		Enum<?> e = (Enum<?>)o;
		return String.format("%s_%s_c",e.getClass().getSimpleName(),e.name()); 
	}

}
